package com.hua.designpattern.j2eepattern.filterinterceptor;

public class FilterEncoding implements FilterInterface {

	private String encodeing = "ISO-8859-1";

	@Override
	public void init(String congfig) {
		this.encodeing = congfig;
	}

	@Override
	public void doFilter(String request, String response, FilterChain filterChain) {
		if (request.contains("ISO-8859-1")) {
			request.replaceAll("ISO-8859-1", encodeing);
			System.out.println("ISO-8859-1" + " (change to) " + encodeing);
		} else {
			System.out.println("do not replace any code");
		}
		filterChain.doFilter(request, response);
	}

	@Override
	public void destroy() {
		encodeing = "ISO-8859-1";
	}

}
